﻿using System.Collections.Concurrent;

namespace LogNet6;

public sealed class LoggerProvider : ILoggerProvider
{
    private readonly ConcurrentDictionary<string, Logger> _loggers = new(StringComparer.OrdinalIgnoreCase);
    private readonly ILoggerProcessor _Processor;
    public LoggerProvider(ILoggerProcessor processor) => _Processor = processor;

    public ILogger CreateLogger(string categoryName) => _loggers.GetOrAdd(categoryName, new Logger(categoryName, _Processor));


    public void Dispose() => _loggers.Clear();
}
